package io.yizoo.business.controller;

import io.elm.core.CoreController;
import io.yizoo.business.entity.*;
import io.yizoo.system.entity.sys_org;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.EnumSet;
import java.util.List;


@RestController
@RequestMapping("/business/hrm/daily/show")
public class hrm_daily_showController extends CoreController {

    @PostMapping("/GetData")
    public Object GetData(@RequestBody String jsonStr) {
        List<?> ret = Ctor.CoreMapper.USelect(
                Ctor.DMaker(jsonStr).Selector
                        .Select("t.work,t.create_date,ifnull(a.name,t.create_user) as user_mc,c.name as org_mc,ifnull(t.hour,0) as hour")
                        .From(biz_hrm_daily.class,"t")
                        .LeftJoin(biz_hrm_ei_basic.class,"a","a.emp_code=t.create_user")
                        .LeftJoin(biz_hrm_ei_rel_org.class,"b","b.ei_id=a.id and b.pm=1")
                        .LeftJoin(sys_org.class,"c","b.org_id=c.id")
                        .IsWhere("and c.id = #{org}","org")
                        .IsWhere("and t.create_date >= #{startDate}", "startDate")
                        .IsWhere(" and t.create_date <= #{endDate}","endDate")
                        .OrderBy("c.name,t.create_user")
                        .GetFactor());
        return JsonResult(ret);
    }
}
